package com.exercise.widgets.buttons

import android.content.Context
import android.content.Intent
import android.view.LayoutInflater
import android.widget.Button
import android.widget.Toast
import com.exercise.struct.base.BaseActivity
import com.exercise.struct.viewmodel.BaseViewModel
import com.exercise.widgets.R
import com.exercise.widgets.databinding.ActivityButtonsBinding

class ButtonsActivity : BaseActivity<BaseViewModel, ActivityButtonsBinding>() {
    override val bindingInflater: (LayoutInflater) -> ActivityButtonsBinding
        get() = ActivityButtonsBinding::inflate
    override val modelClass: Class<BaseViewModel>
        get() = BaseViewModel::class.java

    override fun initData() {
    }

    override fun initView() {
        binding.run {
            toggleButton.addOnButtonCheckedListener { toggleButton, checkedId, isChecked ->
                val text = findViewById<Button>(checkedId).text
                Toast.makeText(this@ButtonsActivity, text, Toast.LENGTH_SHORT).show()
            }
        }
    }

    companion object {
        fun start(context: Context) {
            Intent(context, ButtonsActivity::class.java).also {
                context.startActivity(it)
            }
        }
    }
}